feat(providers): add context compaction across harnesses - #8808
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning Your free Security trial is over. An organization admin can activate Security or dismiss this notice. Comment |
There was a problem hiding this comment.
One consistency finding on the compaction gating in apps/web/src/components/ChatView.tsx. The rest of the web diff (removed Claude-specific gating in ChatComposer.tsx, updated timeline label expectation) looks fine.
Posted via Macroscope — UI Consistency
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a substantial, user-facing compaction capability across five provider harnesses, including native integrations, fallback turns, asynchronous event coordination, and new turn gating. Its cross-cutting production impact and broadened default command availability warrant human review. You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
One finding: the new OpenCode compaction abort path puts a pretty-printed Cause into a caller-visible reason field. Details inline.
Posted via Macroscope — Effect Service Conventions
902f3fa to
54662f3
Compare
54662f3 to
fe487bc
Compare
f303874 to
f91d86e
Compare
f91d86e to
6d0359e
Compare
6d0359e to
d45c3b4
Compare
# Conflicts: # apps/web/src/components/chat/ChatComposer.tsx
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 804e751. Configure here.
## What's Changed * feat(desktop): browser profiles for the preview browser by @juliusmarminge in pingdotgg/t3code#7254 * refactor(shared): move the node:sqlite Effect SQL client into shared by @juliusmarminge in pingdotgg/t3code#7272 * feat(web): add opt-in panel animations by @maria-rcks in pingdotgg/t3code#8830 * feat(projects): automatically pull clean default branches by @maria-rcks in pingdotgg/t3code#9277 * fix(web): show pull request state icons in tabs by @flamboh in pingdotgg/t3code#9112 * feat(providers): add context compaction across harnesses by @maria-rcks in pingdotgg/t3code#8808 * feat(web): add proactive panels by @maria-rcks in pingdotgg/t3code#9276 * fix(web): unify control sizing across settings pages by @juliusmarminge in pingdotgg/t3code#9281 * fix(web): offer browser profiles from the empty-panel launcher by @juliusmarminge in pingdotgg/t3code#9279 * Revert "feat(providers): add context compaction across harnesses" by @maria-rcks in pingdotgg/t3code#9284 * fix(web): show scroll-to-end as soon as the last message slips under the composer by @juliusmarminge in pingdotgg/t3code#9280 * fix(cursor): honor auto and full access modes by @maria-rcks in pingdotgg/t3code#9283 * fix(desktop): detect installed Spectre libs for Windows builds by @juliusmarminge in pingdotgg/t3code#9285 * fix(pull-requests): missing features & better behaviour by @maria-rcks in pingdotgg/t3code#9188 * fix(providers): discover workspace skills everywhere by @maria-rcks in pingdotgg/t3code#9180 * fix(server): preserve automatic settlement timestamps by @eimexdev in pingdotgg/t3code#9254 * fix(opencode): show Reasoning selector for OpenCode models by @maria-rcks in pingdotgg/t3code#9287 * feat(web): preview document attachments in the file viewer by @juliusmarminge in pingdotgg/t3code#9292 * chore(ci): narrow the UI consistency check-run agent by @juliusmarminge in pingdotgg/t3code#9297 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260902.1261...v0.0.39-nightly.20260903.1262 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260903.1262
Merges 137 upstream commits (`d937e3075..36c4e9c`) into the fork, following the `fork-upstream-merge` skill. Landed as a merge commit; conflicts resolved by the inventory's cached verdicts. ## Merge shape 816 files landed (`git diff --stat HEAD^1 HEAD`) against 811 in the upstream range; fork delta 650 files. The gap of five is all in landed and not the range: two fork-owned files touched during resolution (`sandboxControl.placement.test.tsx` test-prop fixup, `useSandboxCommandsBanner.tsx` reformat) plus the three fork docs this merge writes (`inventory.json`, `gaps.md`, `upstream-merge-log.md`). No upstream work was dropped. ## Conflicts Resolved by inventory verdict — `AGENTS.md` (kept the fork's slimmed shape, added Antigravity to the provider list), `contracts/rpc.ts` and `environment.ts`, the ChatView/MessagesTimeline thread-fork + message-origin convergence, the preview cluster (`addBrowserSurface` `profileId` beside the fork's `url`, `rightPanelStore` `openAttachment` beside `retargetFile`), the settings gates, and the two upstream pingdotgg#9364 test deletions. Two latent fork bugs surfaced and were fixed: `PreviewView`'s hosted annotation handler called an unexported helper, now routed through the exported `capturePreviewAnnotationScreenshot` wrapper (matching the sibling native handler); and `ChatView` passed a `configuredUrls` prop the fork's hosted `PreviewPanel` does not accept. ## Unsupported methods `unsupported-methods.mjs` reported ADD 10; recomputed to 0 by adding `UnsupportedMethodError` to the shared `ProviderSetupRpcError` union (nine `provider.auth.*` / `provider.install.*` methods) and to `server.refreshUsageRates`. `gaps.md` grown with a _Provider setup_ bullet and a `refreshUsageRates` clause on _Usage summary_. The three DROP entries (`scripts.run`, `subtasks.list`, `threads.getShell`) are the documented keep-anyway exceptions — `apps/server` still refuses them. ## Feature classification **Usable as-is** (UI only, no backend dependency): mod+w tab close (pingdotgg#9363), PageUp/PageDown chat nav (pingdotgg#9315), diff/PR file tree (pingdotgg#9330), diff-header copy path (pingdotgg#2403), error-report copy (pingdotgg#9166), opt-in context-window indicator (pingdotgg#9190), opt-in panel animations (pingdotgg#8830), proactive panels (pingdotgg#9276), button press feedback (pingdotgg#9349), provider-editor redesign chrome (pingdotgg#8508). **Unsupported in Moatless** (resolve to a refusal): Antigravity provider auth/install and all `provider.*` setup (pingdotgg#9348, pingdotgg#8508), `server.refreshUsageRates`. Desktop-only and already capability- or desktop-gated, so no new fork work: preview browser profiles (pingdotgg#7254), open-links-in-app (pingdotgg#9339), ssh-host suggestions (pingdotgg#9171), environment-as-machine (pingdotgg#9299), continue-threads-across-restart (pingdotgg#9167, rides the new `serverUpdateThreadContinuation` capability). **Backend behavior to reproduce** if Moatless wants it: project icons (pingdotgg#9137, migration 047), auto-pull clean default branches (pingdotgg#9277, migration 045), inline citations (pingdotgg#9146, needs the backend to emit them), the usage page. Migration 046 (RepairAutomaticSettlementTimestamps) is upstream-server-only. Net-zero: context compaction (pingdotgg#8808) landed and was reverted (pingdotgg#9284). ## Verification `fmt:check`, `lint`, `typecheck`, `tripwires` and `inventory-check` green. Full test suite green — one web test failed initially (`addBrowserSurface.test.ts` did not expect the converged default `profileId`), fixed and re-run. Two `verify.mjs` checks exit non-zero and are the caveated machine failures: `unsupported-methods` on the three documented DROP exceptions above, and `duplicate-adds` on three confirmed false positives (`openPreview` in a `ChatView` object literal vs its deps array; three distinct `it()` blocks in `addBrowserSurface.test.ts`). Written by Claude Opus 5 in Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Moatless task: https://moatless.soaplabstest.com/tasks/4e881239-73d1-4a93-9563-6a926e920b42

Adds
/compactas a shared provider command for Claude, Codex, Cursor, Grok, and OpenCode, routing each through its native compaction path. Compaction now emits a work-log entry with before and after token counts when the provider reports them, and web and desktop expose Compact context for any supported provider. Verified with focused server and web tests, scoped typechecks and lint, and a real T3 Code Codex app-server compaction from 83,995 to 7,603 tokens. Browser recordings were captured as T3 evidence artifacts. Built with gpt-5.6-sol in the T3 Code Codex harness.Note
Medium Risk
Compaction coordinates async provider behavior with turn-start gating and pending-state cleanup; incorrect terminal-event handling could leave threads blocked or show wrong activity, though tests cover several rejection paths.
Overview
Introduces a first-class
compactThreadpath on the provider stack so/compactis handled outside normal turns: adapters implement native compaction (Codex, OpenCode, Claude) or the service falls back to a slash-command turn (e.g. Cursor/compress), with completion tracked via runtime events and a synthesizedthread.state.changedwhen needed.Orchestration treats a bare user
/compactas compaction: it requires prior conversation, blocks overlap with running turns or in-flight compaction, and surfaces validation failures through provider activities (includingProviderAdapterValidationErrordetail). Projections clear pending turn starts whenprovider.turn.start.failedmatches the request.UI generalizes manual compaction from Claude-only to any provider that advertises the shared
COMPACT_SLASH_COMMAND; the context meter and slash menu gate/compactaccordingly. Work-log compaction entries can show before → after token counts when providers emit them (notably Claudecompact_boundary).Reviewed by Cursor Bugbot for commit f5b7a12. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add context compaction to
ProviderServiceand provider adapterscompactThreadtoProviderServiceand provider adapters (Claude, Codex, OpenCode), using native provider compaction where supported or fallback commands like/compactand/compress.ProviderCommandReactorprocesses/compactmessages, validates conversation state, and rejects ordinary turns while compaction is active. Failures are recorded as "Context compaction failed".ChatComposerand mobile composer expose manual compaction based on the provider's advertisedcompactslash command instead of hardcoding the Claude provider.ProjectionPipelineto delete pending turn starts on matchingprovider.turn.start.failedactivities.ProviderCommandReactorrejects ordinary turns with a failure activity while compaction is active;OpenCodeAdapterrejects compaction during an active turn.Macroscope summarized f5b7a12.